function editProfile() {
    document.getElementById('personalInfoFields').disabled = false;
}

function populateUserInfo() {
    var who = JSON.parse(localStorage.getItem("loggedinUser"));
    var users = JSON.parse(localStorage.getItem("users"));

    //find the person who is logged in 
    const user = users.find(u => u.email === who["email"]);

    document.getElementById("nameInput").value = user['name'];
    document.getElementById("locationInput").value = user['location'];
    document.getElementById("weightInput").value = user['weight'];

}
populateUserInfo();
 
function saveProfile() {
    const name = document.getElementById("nameInput").value;
    const location = document.getElementById("locationInput").value;
    const weight = document.getElementById("weightInput").value;

    var who = JSON.parse(localStorage.getItem("loggedinUser"));
    var users = JSON.parse(localStorage.getItem("users"));

    //find the person who is logged in 
    const user = users.find(u => u.email === who["email"]);

    user['name'] = name;
    user['location'] = location;
    user['weight'] = weight;

    localStorage.setItem("loggedinUser", JSON.stringify(user));
    localStorage.setItem("users", JSON.stringify(users));

    alert("Personal Info Saved");
    document.getElementById('personalInfoFields').disabled = true;


}